package com.demo.view;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.view.View;

import com.demo.tf.R;
import com.demo.tf.TheFourth;

public class TagButton extends View{
	private Bitmap numBg;
	private String content;
	private int distance;
	public TagButton(TheFourth tf) {
		super(tf);
		// TODO Auto-generated constructor stub
		numBg = BitmapFactory.decodeResource(tf.getResources(), R.drawable.num);
	}

	
	
	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		Paint paint = new Paint();		
		paint.setColor(Color.WHITE);
		paint.setAlpha(255);
		canvas.drawBitmap(numBg, 0, 0, paint);
		//canvas.drawBitmap(numBg, 0, 53, paint);
		paint.setAntiAlias(true);
		paint.setTextAlign(Paint.Align.CENTER);
		canvas.drawText(content, 37, 37, paint);
		canvas.drawText(String.valueOf(distance), 14, 13, paint);
	}



	@Override
	public void setBackgroundResource(int resid) {
		// TODO Auto-generated method stub
		super.setBackgroundResource(resid);
	}

	@Override
	public void setOnClickListener(OnClickListener l) {
		// TODO Auto-generated method stub
		super.setOnClickListener(l);
	}

	@Override
	public void setId(int id) {
		// TODO Auto-generated method stub
		super.setId(id);
	}

	@Override
	public Drawable getBackground() {
		// TODO Auto-generated method stub
		return super.getBackground();
	}
	
	public void setContent(String content,int distance){
		this.content = content.length()>8?content.substring(0, 8):content;
		this.distance = distance;
	}
}
